unit ActiveXForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,ComObj, AxCtrls, ActiveX,BaseInterFace_TLB;

type
  TFActiveXForm = class(TActiveForm)
  private
    FEvents: IFActiveFormXEvents;
    function GetOleCaption: String;
    procedure SetOleCaption(const Value: String);
    { Private declarations }
  protected
    property Events: IFActiveFormXEvents read FEvents write FEvents;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Initialize; override;
    function DoEvent(AEventName: String; AInParams: OleVariant): OleVariant;
    property OleCaption: String read GetOleCaption write SetOleCaption;
  end;

var
  FActiveXForm: TFActiveXForm;

implementation

{$R *.dfm}

{ TFActiveXForm }

constructor TFActiveXForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

end;

destructor TFActiveXForm.Destroy;
begin

  inherited Destroy;
end;

function TFActiveXForm.DoEvent(AEventName: String;
  AInParams: OleVariant): OleVariant;
var
  i, iHigh: Integer;
  InParams: OleVariant;
begin
  if FEvents <> Nil then
  begin
    if VarIsArray(AInParams) then
      iHigh := VarArrayHighBound(AInParams, 1)
    else if (Not VarIsNull(AInParams)) and (Not VarIsClear(AInParams)) then
      iHigh := 0
    else
      iHigh := -1;
    Inc(iHigh);
    InParams := VarArrayCreate([0, iHigh], varVariant);
    InParams[0] := AEventName;
    For i := 1 To iHigh Do
    begin
      if VarIsArray(AInParams) then
        InParams[i] := AInParams[i - 1]
      else if (Not VarIsNull(AInParams)) and (Not VarIsClear(AInParams)) then
        InParams[i] := AInParams;
    end;
    FEvents.OnEvent(InParams, Result);
  end;

end;

function TFActiveXForm.GetOleCaption: String;
begin

end;

procedure TFActiveXForm.Initialize;
begin
  inherited;

end;

procedure TFActiveXForm.SetOleCaption(const Value: String);
begin

end;

end.
